import time

from selenium.webdriver.common.by import By
from autoTest_ecshop.base_page.base import BasePage
from autoTest_ecshop.utils.log_util import logger


class LoginPage(BasePage):
    # # 点击登录
    # btn_loc = (By.XPATH, '//font/a[@href="user.php"]/img')
    # 用户名定位器
    input_username_loc = (By.XPATH,'//*[@name="username"]')
    # 密码定位器
    input_password_loc = (By.XPATH,'//*[@name="password"]')
    # 登录按钮定位器
    btn_login_loc = (By.XPATH, '//*[@name="submit"]')
    # 登录后的验证信息
    homePage_loc = (By.CSS_SELECTOR,'[id="ECS_MEMBERZONE"] > font')

    # 用户名出错的错误信息捕捉
    usernameErr_loc = (By.XPATH,'//div[@align="center"]/div/p[1]')

    def loginSystem(self,username,password):
        # # 点击登录
        # logger.info("点击登录按钮")
        # self.btn_data(self.btn_loc)
        # 输入用户名
        logger.info("输入用户名")
        self.input_data(self.input_username_loc, username)
        # 输入密码
        logger.info("输入密码")
        self.input_data(self.input_password_loc, password)
        # 确认登录
        logger.info("点击确认登录按钮")
        self.btn_data(self.btn_login_loc)

        return self.get_text(self.usernameErr_loc)





